package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.CmpYH;

/**
 * 
 * @author 
 *
 */
@DAO
public interface CmpYHDAO{
	
	@SQL("SELECT a.*,b.phone AS userPhone,c.phone AS objectUserPhone FROM CmpYH a LEFT JOIN SCBuyer b on a.userId=b.id LEFT JOIN SCBuyer c ON a.objectUserId=c.id WHERE a.deleteFlag=1 #if(:t.appointStatus!=-1){ AND a.appointStatus = :t.appointStatus } #if(:t.objectUserPhone!=''){ AND c.phone LIKE '%##(:t.objectUserPhone)%'} #if(:t.userPhone!=''){ AND b.phone LIKE '%##(:t.userPhone)%'} ORDER BY a.updateAt DESC LIMIT :t.start,:t.length ")
    List<CmpYH> query(@SQLParam("t") CmpYH cmpYH);
		
	@SQL("SELECT count(1) FROM CmpYH a LEFT JOIN SCBuyer b ON a.userId=b.id LEFT JOIN SCBuyer c ON a.userId=c.id WHERE a.deleteFlag=1 #if(:t.appointStatus!=-1){ AND a.appointStatus = :t.appointStatus } #if(:t.objectUserPhone!=''){ AND c.phone LIKE '%##(:t.objectUserPhone)%'} #if(:t.userPhone!=''){ AND b.phone LIKE '%##(:t.userPhone)%'} ")
    int querySize(@SQLParam("t") CmpYH cmpYH);
    
    @SQL("SELECT * FROM CmpYH WHERE id=:1 ")
    CmpYH queryById(int id);
    
    @SQL("UPDATE CmpYH SET appointStatus=:2 WHERE id=:1")
    void updateStatusById(int id,int appointStatus);
	
    @SQL("UPDATE CmpYH SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}